
package oneaccess;

import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.huaweicloud.saaslanding.basic.utils.CheckNullUtil;
import com.huaweicloud.saaslanding.install.SaaslandingInstallApplication;
import com.huaweicloud.saaslanding.install.applicationservice.IdaasService;

/**
 * 功能描述
 *
 * @since 2022-03-24
 */

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SaaslandingInstallApplication.class, webEnvironment = RANDOM_PORT)
public class OneAccessOrgTest {

    private IdaasService idaasService;

    @Autowired
    public void setOneAccessApi(IdaasService idaasService) {
        this.idaasService = idaasService;
    }

    @Test
    public void getOrg() {
        System.out.println(idaasService.getOrganization("20220328175828145-9A74-A0C40794"));
    }

    @Test
    public void deleteOrg() {
        if (CheckNullUtil.isNotNull(idaasService.getOrganization("20220328175828145-9A74-A0C40794"))) {
            idaasService.deleteOrganization("20220328175828145-9A74-A0C40794");
        }
    }

    @Test
    public void getAndDeleteOrg() {
        if (CheckNullUtil.isNotNull(idaasService.getOrganization("20220328175828145-9A74-A0C407944"))) {
            idaasService.deleteOrganization("20220328175828145-9A74-A0C407944");
        }
    }

}
